function runTests() {
	write('<h2>Running tests with 1,000,000...</h2>');
	testOne();
	testTwo();
	testThree();
	testFour();
}

function testOne() {
	// traditional way
	var t1 = new Date();
	for (var i = 0; i < 1000000; ++i) {
		var tmp = (i / 2) / 2;
	}
	var t2 = new Date();
	write('<h3>Simple loop @ ' + ((t2 - t1) / 100 ) + ' seconds</h3>');
}

function testTwo() {
	// bitwise
	var t1 = new Date();
	for (var i = 0; i < 1000000; ++i) {
		var tmp = (i >> 1) >> 1;
	}
	var t2 = new Date();
	write('<h3>Bitwise loop @ ' + ((t2 - t1) / 100 ) + ' seconds</h3>');
}

function testThree() {
	// bitwise and do...while
	var t1 = new Date();
	var i = 1000000;
	do {
		var tmp = (i >> 1) >> 1;
		--i;
	} while(i > 0);
	var t2 = new Date();
	write('<h3>Bitwise do...while loop @ ' + ((t2 - t1) / 100 ) + ' seconds</h3>');
}

function testFour() {
	var loop = "\
		var tmp = 2;\
		for (var i = 0; i=arr.length; ++i) {\
			var tmp = i / 2;\
			var tmp = 4 / 2;\
		}\
	";
	var cond = "var i = 0; i < arr.length; i++";
	// find for...loop
	var test1 = /for\s?[(]*[\w\s.,;=+<>!]+[)]*/;
	
	// optimize condition
	 // pre-increment
	 var test2 = /\w\+{2}/;
	 // cached arr length
	 var test3 = /\w{1,}.length/;
	
	// find division
	var test4 = /\w+\s?\/{1}\s?2/;
	
	//alert(loop.replace(test4, '++$1'));
	
}

function write(str) {
	document.getElementById('output').innerHTML += str;
}